/**
 * ReporterServices.java
 * 2008-3-13
 * 作者 Administrator
 */
package org.jackysoft.service;

import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;

import org.jackysoft.data.IDataProvider;
import org.jackysoft.entity.Department;
import org.jackysoft.entity.Product;
import org.jackysoft.entity.ProductFresh;
import org.jackysoft.entity.ProductQuota;
import org.jackysoft.entity.ProductType;
import org.jackysoft.google.collection.ZTreeNode;
import org.jackysoft.report.BadProduct;
import org.jackysoft.util.Page;
import org.springframework.dao.DataAccessException;

/**
 * @author Administrator
 * 
 */
public interface ProductService extends IDataProvider<String,Product>{
	
	Product getPrue(String id) throws DataAccessException;
	
	Product getPureofName(String name)throws DataAccessException;
	
	
    Collection<Product> search(String code) throws DataAccessException;
    
    Collection<Product> searchbad(String code) throws DataAccessException;
        
    Collection<Product> search(String code,Department dept) throws DataAccessException;
    
    Collection<BadProduct> badCodes()  throws DataAccessException;
    
    
	Collection<Product> getsTyped(ProductType itemType)	throws DataAccessException;
	
	Collection<Product> getsTypedOfGrouped(ProductType itemType)	throws DataAccessException;
	
	Collection<Product> getsTyped(ProductType itemType,Department dept)	throws DataAccessException;

	Collection<Product> gets(Department department) throws DataAccessException;
	
	Page gets(Integer start,Integer offset,Department department)throws DataAccessException;
	
	
	Collection<Department> providers(Product product)throws DataAccessException;
	
	boolean ofDepartment(Department dept, Product product);
	
	List<String> importProducts(InputStream stream,String deptName) throws DataAccessException;
	
	byte[] exportProducts() throws DataAccessException,Exception;
	
	
	Collection<ProductQuota> getsQuotas(String code)  throws DataAccessException;
	
	Collection<ProductQuota> getsQuotas(Product pdt)  throws DataAccessException;
	
	int getQuotaCount(String code) throws DataAccessException;
	/**
	 * 计算两个产品之间的定额关系
	 **/
	ProductQuota calculateQuota(Product parent,Product child) throws DataAccessException;
	
	
	
	void createQuota(Collection<ProductQuota> quotas)  throws DataAccessException;
	void createSingleQuota(ProductQuota quota) throws DataAccessException;
	void updateSingleQuota(ProductQuota quota) throws DataAccessException;
	void removeQuota(Collection<ProductQuota> quotas)  throws DataAccessException;
	void cleanAllQuota() throws DataAccessException;
	void updateQuota(Collection<ProductQuota> quotas)  throws DataAccessException;
	
	Collection<ProductFresh> getFreshs() throws DataAccessException;
	/**
	 * @return 该产品的定额子项
	 * @param parentId 父ID
	 * */
	Collection<ZTreeNode> getProductTree(String parentId,Department dept,ProductType itemType) throws DataAccessException;
	
	void updatePrice(File file)throws DataAccessException;
}
